let up = [];
for (var i = 65; i < 90; i++) {
    up.push(String.fromCharCode(i))
}

let lower =  []
for (var i = 97; i < 122; i++) {
    lower.push(String.fromCharCode(i))
}

let num = []
for (var i = 48; i < 57; i++) {
    num.push(String.fromCharCode(i))
}

const Randow = {
    lower,
    up,
    num,

    //获取随机激活码传，激活码长度（数字+小写），len：字符串长度
    getActication:function (len) {
        let arr = []

        let newCase = this.lower.concat(this.num)

        for (var i = 0 ; i < len ; i++){
            arr.push(newCase[parseInt(Math.random()*(newCase.length))])
        }

        return arr.join('')
    },
    //获取订单编号随机数（全数字），len：字符串长度
    getOrderNumber:function (len) {
        let arr = []

        arr.push('510')

        let newCase = this.num

        for (var i = 0 ; i < (len-'510'.length); i++){
            arr.push(newCase[parseInt(Math.random()*(newCase.length))])
        }

        return arr.join('')
    },
    //获取卡号随机数（固定头部+可变长度字符串），card_header：卡号头部（字符串）
    getCardNumber:function (card_header) {
        let arr = []

        card_header = String(card_header)

        let newCase = this.num

        arr.push(card_header)

        for (var i = 0 ; i < (16-card_header.length) ; i++){
            arr.push(newCase[parseInt(Math.random()*(newCase.length))])
        }

        return arr.join('')
    }
}

module.exports = Randow
